<?

class database
{
    # Database vars
    var $user = DB_USER;
    var $pass = DB_PASS;
    var $host = DB_HOST;
    var $name = DB_NAME;

    # Function that returns mysql num_rows
    function num_rows($sql)
    {
        $this->connect();
        $res = mysql_query($sql);
        $aantal = mysql_num_rows($res);
        mysql_close();
        return $aantal;
    }

    # Function that returns mysql_fetch_array
    function get_array($sql)
    {
        $this->connect();
        $res = mysql_query($sql);
        while($data = mysql_fetch_array($res))
        $row[] = $data;
        mysql_close();
        return $row;
    }

    # Same as above only one row
    function get_single($sql)
    {
        $this->connect();
        $res = mysql_query($sql);
        $data = mysql_fetch_array($res);
        mysql_close();
        return $data;
    }

    # Function running a normal query
    function execute($sql)
    {
        $this->connect();
        $res = mysql_query($sql);
        mysql_close();
        return $res;
    }

    function connect()
    {
        return mysql_select_db($this->name, mysql_connect($this->host, $this->user, $this->pass));
    }
}
?> 